# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=htcap
pkgver=155.a59c592
pkgrel=8
epoch=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner')
pkgdesc='A web application analysis tool for detecting communications between javascript and the server.'
arch=('any')
url='https://github.com/segment-srl/htcap'
license=('GPL3')
depends=('python' 'python-simplejson' 'phantomjs')
makedepends=('git')
source=("git+https://github.com/segment-srl/$pkgname.git"
        'socks.py.patch')
sha512sums=('SKIP'
            '16256475c7e21bb970b21bc3e67f80ae9d72b3e22cec739b51566aba35b1871c5c030d029fc03180f5554e25692abb49af481169baab42a7a1b60e9a5b09f17a')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  patch -p2 < ../socks.py.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

